Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate handling of internal tags #661

Merged
merged 7 commits into from
Apr 14, 2021
Merged

Conversation

Julow
Copy link
Collaborator

@Julow Julow commented Apr 13, 2021

Fixes #632 (comment)

Internal tags are used to change Odoc's behavior and are never rendered. This caused Stdlib modules to have no synopsis because the @canonical tag was found before any synopsis could be extracted.

This PR handles these tags (@canonical, @inline, @open and @closed) earlier in the pipeline and removes them from the model.

This isn't the only solution to this problem but I think it's a nice refactoring to have. I believe regular tags should also be handled (previous discussion).

Copy link
Collaborator Author

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a warning in case an internal tag is unhandled (eg. @inline on an item that isn't an include or @canonical on a value), for the same reason as for removing the placeholder in case of syntax error.

@@ -4,6 +4,8 @@ top-comment.
The module Test__X is expected to be referenced through Test.X.

$ compile test__x.mli test.ml
File "test.ml", line 15, characters 6-24:
Unexpected tag '@canonical' at this location.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected. This @canonical tag is indeed unhandled.
This PR implements the required refactoring to fix this easily, though.

Comment on lines -212 to -215
Error.warning status.warnings e;
let placeholder = [ `Word "@canonical"; `Space " "; `Code_span s ] in
let placeholder = List.map (Location.at location) placeholder in
Error (Location.at location (`Paragraph placeholder)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this placeholder logic. This tag isn't intended to be rendered. If it contains a syntax error, only the programmer need to be informed (through a warning) and not users reading the documentation.

Julow added 3 commits April 13, 2021 15:53
Internal tags are used to change Odoc's behavior and are never rendered
(@canonical, @inline, @OPEN and @closed).
This handles them earlier and removes them from the description of
comments.
Handle tags as soon as possible instead of passing them around.
This ensures that internal tags are always handled.
It was possible to attach those tags to anything and would be ignored if
unecessary.
This emits a warning in this case.
@jonludlam
Copy link
Member

Other than that minor point, I think this is a really nice change.

Comment on lines 16 to 17
File "a.mli", line 4, characters 4-17:
Unexpected tag '@canonical' at this location.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't expected however. This is caused by `Root paths to not be valid canonical paths, I'll add a different warning for this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added a specific warning for this case.

Julow added 2 commits April 14, 2021 11:12
This case was ignored until now. Since the warning about unexpected tag
was added, this case is reported incorrectly.
@jonludlam jonludlam merged commit 3438afc into ocaml:master Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No synopsis rendered for modules for Stdlib modules
2 participants